/**
 * Project: ServletDemo
 * File Created at 2012-8-26下午10:58:46
 */
package demo.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

/**
 * 日志filter，用来记录客户端和请求的所有信息
 * 
 * @author Administrator
 * 2012-8-26下午10:58:46
 */
public class LoggingFilter implements Filter{

    /**
     * @author Administrator
     * 2012-8-26下午10:59:01
     */
    @Override
    public void init(FilterConfig arg0) throws ServletException {
        System.out.println("LoggingFilter 初始化 -0");
        
    }
    
    /**
     * @author Administrator
     * 2012-8-26下午10:59:01
     */
    @Override
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
            throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest)req;
        System.out.println("===>LoggingFilter.java被调用 -0");
        System.out.println("拦截 URI="+request.getRequestURI());
        chain.doFilter(req, res);
    }
    
    /**
     * @author Administrator
     * 2012-8-26下午10:59:01
     */
    @Override
    public void destroy() {
        // TODO Auto-generated method stub
        
    }

}
